<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <h1>这是index页面</h1>
    <button class="but">点击跳转页面</button>
    <a href="./a.html?name=lisi&age=21">这是a连接</a>
    <script>
        var obj = {
            name: "zhangsan",
            age: 21,
        };
        document.getElementsByClassName("but")[0].onclick = function() {
            window.location.href = `./a.html?name=${obj.name}&age=${obj.age}`;
        };
    </script>
</body>

</html>